package com.qfedu.yanglao20admin.health.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.yanglao20.common.CommonResult;
import com.qfedu.yanglao20.common.param.PageParam;
import com.qfedu.yanglao20admin.health.entity.HealthData;
import com.qfedu.yanglao20admin.health.service.HealthDataService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (HealthData)表控制层
 *
 * @author makejava
 * @since 2023-04-23 19:19:44
 */
@Api(tags = "健康信息管理")
@RestController
@RequestMapping("healthData")
public class HealthDataController {
    /**
     * 服务对象
     */
    @Resource
    private HealthDataService healthDataService;

    /**
     * 分页查询
     *
     * @param
     * @param
     * @return 查询结果
     */

    @ApiOperation(value = "分页展示应用服务信息", notes = "分页展示应用服务信息")
    @GetMapping("/page")
    public CommonResult<PageParam> page(com.qfedu.yanglao20admin.health.param.HealthData param) {
        Page<HealthData> healthData = healthDataService.pageHealthdata(param);
        return CommonResult.success(healthData);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询单挑数据", notes = "根据id查询单挑数据")
    @GetMapping("{id}")
    public ResponseEntity<HealthData> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.healthDataService.queryById(id));
    }

//    /**
//     * 新增数据
//     *
//     * @param healthData 实体
//     * @return 新增结果
//     */
//    @ApiOperation(value = "新增健康数据信息", notes = "新增健康数据信息")
//    @PostMapping
//    public ResponseEntity<HealthData> add(HealthData healthData) {
//        return ResponseEntity.ok(this.healthDataService.insert(healthData));
//    }

    /**
     * 编辑数据
     *
     * @param healthData 实体
     * @return 编辑结果
     */
    @ApiOperation(value = "编辑健康数据信息", notes = "编辑健康数据信息")
    @PutMapping
    public ResponseEntity<HealthData> edit(HealthData healthData) {
        return ResponseEntity.ok(this.healthDataService.update(healthData));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @ApiOperation(value = "根据id删除健康数据信息", notes = "根据id删除健康数据信息")
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.healthDataService.deleteById(id));
    }

}

